API Documentation
Public Member Functions | List of all members
nkMaths::Quaternion Class Reference

A quaternion, symbolizing rotations as a 4D vector. More...

Inheritance diagram for nkMaths::Quaternion:
nkMaths::Vector

Public Member Functions

 Quaternion ()
 
 Quaternion (float a, float b, float c, float w)
 
 Quaternion (const Vector &axis, float angle)
 
 Quaternion (const Vector &eulerAngles)
 
 Quaternion (const Matrix &mat)
 
 Quaternion (const Quaternion &other)
 
 Quaternion (const DirectX::XMVECTOR &value)
 
 ~Quaternion ()
 
Vector getAsEulerAngles () const
 
void setFromAxisAngle (const Vector &axis, float angle)
 
void setFromEuler (const Vector &angles)
 
void setFromMatrix (const Matrix &mat)
 
Quaternionoperator= (const Quaternion &other)
 
Quaternion operator* (const Quaternion &other) const
 
void operator*= (const Quaternion &other)
 
- Public Member Functions inherited from nkMaths::Vector
 Vector ()
 
 Vector (float x, float y)
 
 Vector (float x, float y, float z)
 
 Vector (float x, float y, float z, float w)
 
 Vector (const Vector &other)
 
 Vector (const IVector &other)
 
 Vector (const DirectX::XMVECTOR &value)
 
 ~Vector ()
 
float getX () const
 
float getY () const
 
float getZ () const
 
float getW () const
 
DirectX::XMVECTOR getValues () const
 
void setX (float value)
 
void setY (float value)
 
void setZ (float value)
 
void setW (float value)
 
void addX (float value)
 
void addY (float value)
 
void addZ (float value)
 
void addW (float value)
 
void multX (float value)
 
void multY (float value)
 
void multZ (float value)
 
void multW (float value)
 
void normalizeAsVec2 ()
 
Vector getNormalizedAsVec2 () const
 
void normalizeAsVec3 ()
 
Vector getNormalizedAsVec3 () const
 
void normalizeAsVec4 ()
 
Vector getNormalizedAsVec4 () const
 
float dotProductAsVec2 (const Vector &other) const
 
float dotProductAsVec3 (const Vector &other) const
 
float dotProductAsVec4 (const Vector &other) const
 
void setAsCrossVec2 (const Vector &other)
 
Vector getCrossVec2 (const Vector &other)
 
void setAsCrossVec3 (const Vector &other)
 
Vector getCrossVec3 (const Vector &other) const
 
void setAsCrossVec4 (const Vector &other1, const Vector &other2)
 
Vector getCrossVec4 (const Vector &other1, const Vector &other2) const
 
float getLength () const
 
float getLengthSquared () const
 
float getDistanceSquared (const Vector &other) const
 
float getDistance (const Vector &other) const
 
void fromString (const std::string_view &str)
 
Vectoroperator= (const Vector &other)
 
Vectoroperator= (const IVector &other)
 
Vector operator+ (const Vector &other) const
 
void operator+= (const Vector &other)
 
Vector operator- (const Vector &other) const
 
void operator-= (const Vector &other)
 
Vector operator* (const Vector &other) const
 
void operator*= (const Vector &other)
 
Vector operator* (const Quaternion &other) const
 
void operator*= (const Quaternion &other)
 
Vector operator* (const Matrix &mat) const
 
void operator*= (const Matrix &other)
 
Vector operator* (float coeff) const
 
void operator*= (float coeff)
 
Vector operator/ (const Vector &other) const
 
void operator/= (const Vector &other)
 
Vector operator/ (float coeff) const
 
void operator/= (float coeff)
 
bool operator== (const Vector &other) const
 
bool operator!= (const Vector &other) const
 
bool operator< (const Vector &other) const
 
bool operator<= (const Vector &other) const
 
bool operator> (const Vector &other) const
 
bool operator>= (const Vector &other) const
 

Detailed Description

A quaternion, symbolizing rotations as a 4D vector.

Constructor & Destructor Documentation

◆ Quaternion() [1/7]

nkMaths::Quaternion::Quaternion ( )

Default constructor.

◆ Quaternion() [2/7]

nkMaths::Quaternion::Quaternion ( float  a,
float  b,
float  c,
float  w 
)

Filling constructor.

Parameters
aThe a component.
bThe b component.
cThe c component.
wThe w component.

◆ Quaternion() [3/7]

nkMaths::Quaternion::Quaternion ( const Vector axis,
float  angle 
)

Axis angle constructor.

Parameters
axisThe axis of rotation to consider.
angleThe angle around this axis, in radians.

◆ Quaternion() [4/7]

nkMaths::Quaternion::Quaternion ( const Vector eulerAngles)

Euler angles constructor.

Parameters
eulerAnglesThe euler angles.

◆ Quaternion() [5/7]

nkMaths::Quaternion::Quaternion ( const Matrix mat)

Matrix constructor.

Parameters
matThe matrix from which to extract the rotation.

◆ Quaternion() [6/7]

nkMaths::Quaternion::Quaternion ( const Quaternion other)

Copy constructor.

Parameters
otherThe quaternion to copy.

◆ Quaternion() [7/7]

nkMaths::Quaternion::Quaternion ( const DirectX::XMVECTOR &  value)

Filling constructor.

Parameters
valueXM values.

◆ ~Quaternion()

nkMaths::Quaternion::~Quaternion ( )

Destructor.

Member Function Documentation

◆ getAsEulerAngles()

Vector nkMaths::Quaternion::getAsEulerAngles ( ) const
Returns
The quaternion translated as euler angles.

◆ setFromAxisAngle()

void nkMaths::Quaternion::setFromAxisAngle ( const Vector axis,
float  angle 
)

Sets the quaternion from an axis and angle pair.

Parameters
axisThe axis to rotate around.
angleThe angle to rotate, in radians.

◆ setFromEuler()

void nkMaths::Quaternion::setFromEuler ( const Vector angles)

Sets the quaternion from euler angles.

Parameters
anglesThe euler angles to translate.

◆ setFromMatrix()

void nkMaths::Quaternion::setFromMatrix ( const Matrix mat)

Sets the quaternionx from a matrix.

Parameters
matThe matrix to extract the rotation from.

◆ operator=()

Quaternion& nkMaths::Quaternion::operator= ( const Quaternion other)

Assignment operator.

Parameters
otherThe quaternion to assign.

◆ operator*()

Quaternion nkMaths::Quaternion::operator* ( const Quaternion other) const

Multiplication operator.

Parameters
otherThe quaternion to multiply with.
Returns
A quaternion being the result of the multiplication of both quaternions.

◆ operator*=()

void nkMaths::Quaternion::operator*= ( const Quaternion other)

Multiplication and assignment operator.

Parameters
otherThe quaternion to multiply with.

The documentation for this class was generated from the following file: